//对象访问器
var person = {
    firstname: "ma",
    lastname: "hu",
    age: "",
    eyecolor: "blank",
    language: "chinase",
    get lang() {
        return this.language;
    },
    set dream(a) {
        this.age = a;
    }
};

console.log(person.lang)
person.dream = 24;
console.log(person.age)

var animal = {
    type: "",
    eat: "meat",
    fullname: function () {
        return this.eat;
    },
    get fullname1() {
        return this.eat;
    }
};
console.log(animal.fullname())//以函数形式访问
console.log(animal.eat)//以属性形式访问


var person1 = {
    firstname: "ma",
    lastname: "hu",
    age: 23,
    get fullname() {
        return this.firstname.toUpperCase() + this.lastname.toUpperCase();
    }
};
console.log(person1.fullname)



var obj = {
    counter: 0,
    get reset() {
        this.counter = 0;
    },
    get increment() {
        this.counter++;
    },

    get decrement() {
        this.counter--;
    },
    set add(value) {
        this.counter += value;
    },
    set subtract(value) {
        this.counter -= value;
    }
};
obj.reset;
console.log(obj.counter)
obj.add = 5;
console.log(obj.counter)
obj.subtract = 1;
console.log(obj.counter)
obj.increment;
console.log(obj.counter)
obj.decrement;
console.log(obj.counter)